<extend name="Public/base" />
<block name="style">
<!--<link rel="stylesheet" href="__STATIC__/layui/css/layui.css">-->
</block>
<block name="script">
<script src="__STATIC__/layui/layui.js"></script>
<script>
layui.use(['layer','form'], function(){
    var layer = layui.layer;
    var form = layui.form();
    form.verify({
        ad_name: function(value, item){
            if(/^\d+\d+\d$/.test(value)){
                return '广告名称不能全为数字';
            }
        },
        template_id:function(value, item){
            if(value == -1){
              return '请选择广告模版';
            }
        }
    });
}); 
</script>
</block>
<block name="body">
    <div class="main-title">
       <if condition="$istype === 'add' ">
            <h2>新增列表</h2>
        <else />
            <h2>修改列表</h2>
        </if>
    </div>
    <if condition="$istype === 'add' ">
        <form id="form" action="{:U('add')}" method="post" class="form-horizontal layui-form">
    <else />
        <form id="form" action="{:U('edit')}" method="post" class="form-horizontal layui-form">
        <input type="hidden" name="id" value="{$data.id}">
    </if>
        <div id="tab1" class="tab-pane in tab1">
            <div class="form-item cf">
                <label class="item-label">广告名称</label>
                <div class="controls">
                    <input lay-verify="required|ad_name" type="text" placeholder="请输入广告名称" class="text input-large" name="ad_name" <if condition="$istype === 'edit'">value="{$data.ad_name}"</if>>
                </div>
            </div>
            <div class="form-item cf">
                <label class="item-label">广告模版</label>
                <div class="controls">
                    <select lay-verify="required|template_id" name="template_id" lay-ignore>
                    <option value="-1">---请选择---</option>
                    <volist name="templates" id="template">
                        <if condition="$istype === 'edit'">
                            <if condition="$key == $data['template_id']">
                                <option selected value="{$key}">{$template}</option>
                            <else />
                                <option value="{$key}">{$template}</option>
                            </if>
                        <else />
                            <option value="{$key}">{$template}</option>
                        </if>
                    </volist>
                </select>
                </div>
            </div>
            <div class="form-item cf">
                <button lay-submit class="btn submit-btn">确 定</button>
                <button class="btn btn-return" type="reset">重置</button>
            </div>
        </div>
    </form>
</block>